package com.dd.cloud.user.service.admin.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dd.cloud.user.entity.admin.IpWriteList;
import com.dd.cloud.user.mapper.admin.IpWriteListMapper;
import com.dd.cloud.user.service.admin.IIpWriteListService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * ip白名单 服务实现类
 * </p>
 *
 * @author czg
 * @since 2023-12-20
 */
@Service
public class IpWriteListServiceImpl extends ServiceImpl<IpWriteListMapper, IpWriteList> implements IIpWriteListService {

    @Override
    public List<String> getWriteIp(Integer type) {
        QueryWrapper<IpWriteList> qw = new QueryWrapper<>();
        qw.lambda().eq(IpWriteList::getType, 1)
                .eq(IpWriteList::getStatus, 1);
        List<IpWriteList> list = list(qw);
        List<String> res = list.stream().map(item -> {
            return item.getIp();
        }).collect(Collectors.toList());
        return res;
    }
}
